package com.zzyl.nursing.controller.member;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.zzyl.common.core.domain.R;
import com.zzyl.nursing.domain.NursingProject;
import com.zzyl.nursing.dto.BindFamilyDto;
import com.zzyl.nursing.dto.UserLoginRequestDto;
import com.zzyl.nursing.service.INursingProjectService;
import com.zzyl.nursing.vo.BindElderDeviceVo;
import com.zzyl.nursing.vo.LoginVo;
import com.zzyl.nursing.vo.MyFamilyVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.zzyl.common.annotation.Log;
import com.zzyl.common.core.controller.BaseController;
import com.zzyl.common.core.domain.AjaxResult;
import com.zzyl.common.enums.BusinessType;
import com.zzyl.nursing.domain.FamilyMember;
import com.zzyl.nursing.service.IFamilyMemberService;
import com.zzyl.common.utils.poi.ExcelUtil;
import com.zzyl.common.core.page.TableDataInfo;

/**
 * 老人家属Controller
 * 
 * @author ljc
 * @date 2025-03-03
 */
@Api(tags = "老人家属管理")
@RestController
@RequestMapping("/member/user")
public class FamilyMemberController extends BaseController
{
    @Autowired
    private IFamilyMemberService familyMemberService;


    /**
     *  小程序登录
     * @param userLoginRequestDto
     * @return
     */
    @PostMapping("/login")
    @ApiOperation("小程序登录")
    public AjaxResult login(@RequestBody UserLoginRequestDto userLoginRequestDto) {
        LoginVo loginVo = familyMemberService.login(userLoginRequestDto);
        return success(loginVo);
    }

    /**
     *  绑定家人
     * @param bindFamilyDto
     * @return
     */
    @PostMapping("/add")
    @ApiOperation("绑定家人")
    public AjaxResult add(@RequestBody BindFamilyDto bindFamilyDto) {
        familyMemberService.bingFamily(bindFamilyDto);
        return success();
    }

    /**
     *  查询家人列表
     * @param
     * @return
     */
    @GetMapping("/my")
    @ApiOperation("查询家人列表")
    public AjaxResult myFamily() {
        List<MyFamilyVo> myFamilyVoList = familyMemberService.myFamily();
        return success(myFamilyVoList);
    }

    /**
     *  查看已绑定家人列表（分页查询）
     * @param
     * @return
     */
    @GetMapping("/list-by-page")
    @ApiOperation("查看已绑定家人列表（分页查询）")
    public AjaxResult queryPage() {
        List<BindElderDeviceVo> bindElderDeviceVoList= familyMemberService.queryPage();
        return success(bindElderDeviceVoList);
    }
}
